<template>
  <div class="yueke">
    <NavBar title="一对一约课" left-arrow @click-left="onClickLeft" />
    <div class="star_teacher">
      <div v-for="(item,index) in list" :key="index">
        <div @click="getTeach(item)">
          <img :src="item.avatar" alt />
        </div>
        <div>
          <p>
            <span style="color:orange">{{item.real_name}}</span>
          </p>
          <p class="ptext">
            <span>{{item.sex|sex}}</span>
            <span>{{item.teach_age}}年教龄</span>
          </p>
        </div>
        <div>
          <button class="btn" @click="onCom(item.teacher_id)">预约</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { NavBar } from "vant";
import { oneFor } from "../../https/https";
export default {
  components: {
    NavBar,
  },
  methods: {
    getTeach(item) {
      this.$router.push({
        path: "/teachdetail",
        query: {
          id: item.teacher_id,
        },
      });
    },
    onClickLeft() {
      this.$router.go(-1);
    },
    onCom(id) {
      console.log(id);
      this.$router.push({
        path: "/yueke2",
        query: {
          id: id,
        },
      });
    },
  },
  data() {
    return {
      list: [],
      flag: null,
    };
  },
  mounted() {
    oneFor({
      page: 1,
      limit: 10,
      attr_val_id: 6,
    }).then((res) => {
      console.log(res);
      this.list = res;
    });
  },
  filters: {
    sex(val) {
      if (val == 0) {
        return "男";
      } else if (val == 1) {
        return "女";
      }
    },
  },
};
</script>

<style scoped>
.yueke {
  background-color: #eeeeee;
  padding-bottom: 100px;
}
.star_teacher > div {
  width: 90%;
  height: 80px;
  margin: 10px auto;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  font-size: 14px;
  background-color: #ffffff;
  padding-left: 10px;
  border-radius: 15px;
}
.star_teacher > div > div > img {
  width: 50px;
  height: 50px;
  border-radius: 50%;
}
.star_teacher > div > div > p {
  margin-left: 15px;
  margin-bottom: 10px;
}
.ptext {
  width: 200px;
  color: #999;
  font-size: 12px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.ptext > span {
  margin-right: 10px;
}
.btn {
  padding: 5px 10px;
  border-radius: 10px;
  background-color: #eee;
  border: 1px solid rgb(241, 213, 189);
  color: orange;
}
</style>